|
|
|
|
|
|
|
ForeColor property. You can add the optional parameter B or BF after the color parameter to draw boxes and filled boxes, respectively. For example, the following statements draw two boxes on a form: |
|
|
|
|
|
|
|
|
Line (100, 850)-(500, 1800), vbBlue, B
Line -(900, 2450), , BF |
|
|
|
|
|
|
|
|
When you're drawing a box, the coordinates passed to the Line method represent the upper-left and lower-right corners of the box. |
|
|
|
|
|
|
|
|
The Circle method also has many optional parameters. The simplest form of the method is the following: |
|
|
|
|
|
|
|
|
This command draws a circle of radius R with a center at the position specified by X and Y. As with the Line method, the pattern and color of the circle's border and fill are determined by the settings of the object's properties. The full syntax of the Circle method is as follows: |
|
|
|
|
|
|
|
|
Object.Circle [Step] (x,y), radius, [color, start, end, aspect] |
|
|
|
|
|
|
|
|
The start and end arguments are used to draw an arc rather than a full circle. The values of start and end are the angles from horizontal expressed in radians. (The value of an angle in radians is determined by multiplying the angle in degrees by /180.) The values of start and end can range from zero to 2, or zero to 2. If you use a negative value for start and end, the lines are drawn from the center of the circle to both ends of the arc. The following code produces an arc that appears to move around a circle, much like a radar screen: |
|
|
|
|
|
|
|
|
Private Sub Form_Click()
Const PI = 3.14159
Const ARCSIZE = 45
Dim x As Integer, y As Integer, r As Integer
Dim arcstart As Single, arcend As Single
Dim nCount As Integer
'Draw a circle in the middle of the form
x = Me.ScaleWidth / 2
y = Me.ScaleHeight / 2
r = x / 2
Me.DrawMode = vbCopyPen
Me.FillStyle = vbFSTransparent
Me.Circle (x, y), r
'Draw the sweeping radar arc
Me.DrawMode = vbXorPen
Me.FillColor = vbRed
Me.FillStyle = vbSolid
For nCount = 0 To 360
arcstart = nCount
arcend = nCount + ARCSIZE
If arcend > 360 Then arcend = arcend - 360
Me.Caption = "Arc of " & ARCSIZE & " degrees starting at " _
& nCount
Circle (x, y), r, , -arcstart * PI / 180, -arcend * PI / 180
DoEvents |
|
|
|
|
|